(1) Field of the Invention
The present invention relates to a compilation method, and in particular, to a compilation method for converting a source program which is written in an object-oriented language typified by a C++ language, into an object program.
(2) Description of the Related Art
In recent software development, an object-oriented language with high serviceability and reusability has come to attract attention along with a tendency for large-scaled programs. A C++ language is a representative example of the object-oriented language. The C++ language is a language whose specification is extended so that a program can be naturally described in a object-oriented manner in a C language that is a high-level language with an excellent portability. A function is defined using the C++ language in a program, and is called at the right stage so that the processing defined by the function is executed. Two ways are provided here as a method to pass an argument to the function: “pass by value”; and “pass by reference (i.e. pass by pointer)”.
In the conventional C++ language, in the case where an argument is given to a function, a copy of the given argument is generated, and then, stored in a memory. In the case of using the “pass by value”, on one hand, an object to be given as an argument is completely copied, and then, the copy of the argument is stored in the memory. For example, in the case of passing a class object, processing of generating a copy of the class object is firstly executed, and then, the generated class object is stored in the memory. On the other hand, in the case of using the “pass by reference”, an object to be passed is a pointer value (i.e., an address value of an object), therefore, the pointer value is copied and stored in the memory.
It should be noted that the copy of the class object in the “pass by value” may implicitly call many copy constructors, which may be a cause of increase in code size resulted from compilation. In general, codes can be effectively generated by employing “pass by reference” rather than “pass by value”. Therefore, it is considered as important that a programmer performs programming with the “pass by reference” in mind.
This assumption, however, cannot but force the programmer to perform programming so that the codes are efficiently generated.
The use of “pass by reference” may cause a problem of aliasing (a risk of unintentionally changing a status of an object due to a use of plural names for a single object). This causes a problem that bugs can easily enter the program.